package net.gz01.wallet.web.model;

import com.jfinal.plugin.activerecord.Page;
import net.gz01.wallet.common.ZOSearchCondition;
import net.gz01.wallet.common.ZOSqlHelper;
import net.gz01.wallet.web.model.base.BaseDianziz;

public class DianziZH extends BaseDianziz<DianziZH> {
    public static final DianziZH dao = new DianziZH().dao();

    public DianziZH selectByEnable(){
        return super.findFirst("select * from dianziz where enable=1");
    }

    public Page<DianziZH> search(ZOSearchCondition sc){
        int pageNumber = sc.page.getPageNum();
        int pageSize = sc.page.getNumPerPage();

        ZOSqlHelper sql = new ZOSqlHelper(" from dianziz WHERE 1 = 1");
        sql.like("title", sc.get("code"));
        sql.equals("enable", sc.getBoolean("enable"));
        return super.paginate(pageNumber, pageSize, "select *", sql.toString(),sql.getParams());
    }

    public DianziZH selectById(String id){
        return super.findFirst("select * from dianziz where id=" + id);
    }

}
